package com.hzwq.demo.Email.controller;

import com.hzwq.demo.Email.bo.SdteInBox;
import com.hzwq.demo.Email.bo.SdteOutBox;
import com.hzwq.demo.Email.service.SdteInBoxService;
import com.hzwq.demo.Email.service.SdteOutBoxService;
import com.hzwq.demo.Login.controller.LoginController;
import com.hzwq.demo.Login.service.ISdteUserService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class EmailController {

    private static Logger log = Logger.getLogger(LoginController.class);

    @Autowired
    private ISdteUserService iSdteUserService;

    @Autowired
    private SdteInBoxService sdteInBoxService;
    @Autowired
    private SdteOutBoxService sdteOutBoxService;

    @RequestMapping("/mailbox")
    public String mailbox(){
        return "email/mailbox";
    }

    @RequestMapping("/inboxPage")
    public String inboxPage(String userId, Integer pageNo, Integer size){
        SdteInBox entity = new SdteInBox();
        entity.setInboxReceiver(userId);
        Page<SdteInBox> page = sdteInBoxService.findPageEmail(entity, pageNo, size);
        log.info("page===>>>>" + page);
        return "email/inbox";
    }
    @RequestMapping("/inbox")
    public String mail_compose(){
        return "email/inbox";
    }
    @RequestMapping("/mailCompose")
    public String mailCompose(){
        return "email/mailCompose";
    }

    /**
     * 新增写信信息
     * @return
     */
    @RequestMapping("saveOutBox")
    @ResponseBody
    public String saveOutBox(SdteOutBox so){
      sdteOutBoxService.saveOutBox(so);
        return "123";
    }
}
